package Lee_code;

/**
 * @author blh
 * @date 2024年07月02日 16:04
 */
public class Lee_24_72 {
    public ListNode swapPairs(ListNode head) {
        ListNode dummyHead = new ListNode(-1);
        dummyHead.next = head;
        ListNode tempHead = dummyHead;
        while (tempHead.next != null && tempHead.next.next != null) {
            ListNode first = tempHead.next;
            ListNode second = first.next;

            first.next = second.next;
            second.next = first;
            tempHead.next = second;
            tempHead = tempHead.next.next;
        }
        return dummyHead.next;
    }
}
